home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / mebbs / cb_horses.lha / CBHORSES / horses.rexx < prev   
OS/2 REXX Batch file  |  1994-11-16  |  33KB  |  977 lines

  1. /***********************************************************************/
  2. /*                CHALKBOARD HORSES Horse Racing Door                  */
  3. /*                       VARIABLE DECLARATIONS                         */
  4. /***********************************************************************/
  5. /* BBSname   = name of the BBS this pfile is being run on              */
  6. /* Sysopname = name of the sysop offering this pfile                   */
  7. /* Progname  = name of this program                                    */
  8. /* FilePath  = path to subdirectory for support files                  */
  9. /* input     = used in CHECKPANIC procedure to hold input argument     */
  10. /* Uhandle   = Handle of current player                                */
  11. /* Udate     = Current date & time                                     */
  12. /* Uaccess   = User's access number (0,23)                             */
  13. /* CLS       = User's screen clear code                                */
  14. /* AcctBal   = Current player's account balance                        */
  15. /* LowBal    = Flag to signal when player's acct balance is too low    */
  16. /* MaxPlayers= Maximum players allowed                                 */
  17. /* player.i  = 'array' to hold all player handles                      */
  18. /* score.i   = 'array' to hold all player acct balances                */
  19. /* i, j      = simple counters used in various places in program       */
  20. /* temp      = temporary variable used when sorting/swapping           */
  21. /* nplayers  = total number of players in Dplayers files               */
  22. /* Flag      = used to signal different events                         */
  23. /* More      = used to ask if user wants to see more of the score list */
  24. /* Choice    = main menu choice                                        */
  25. /* Another   = does player want to bet on ANOTHER race?                */
  26. /* Hname.i   = horse names                                             */
  27. /* WHorse.i  = horse(s) picked to win, show or place                   */
  28. /* WBet.i    = amount bet to win, show or place                        */
  29. /* WOdds.i   = holds the current "To win" odds on the horses           */
  30. /* POdds.i   = holds the current "To place" odds on the horses         */
  31. /* SOdds.i   = holds the current "To show" odds on the horses          */
  32. /* RNum      = holds random numbers picked for horse race              */
  33. /* Count.i   = holds the cumulative counter for each horse during race */
  34. /* Win       = holds number of WIN horse                               */
  35. /* Place     = holds number of PLACE horse                             */
  36. /* Show      = holds number of Show horse                              */
  37. /* Guessadd  = amount to be added to account ballance in guess game.   */
  38. /* REPS      = holds number of repetitions of the Delay Loop (default) */
  39. /***********************************************************************/
  40. /*                       VARIABLE INITIALIZATIONS                      */
  41. /***********************************************************************/
  42.  
  43. SIGNAL ON SYNTAX
  44. SIGNAL ON IOERR
  45. signal on ERROR
  46. parse arg LineNumber
  47. options results
  48. DoorName = "HORSES"
  49. if( ~show( 'l', "mebbsarexx.library" ) )then do
  50.    if( ~addlib( "mebbsarexx.library", 0, -30, 0 ) )then do
  51.       say "Could not open library"
  52.       exit 10
  53.    end
  54. end
  55. ver = "     Chalkboard Downs v.160 by /\/\r. Ed"
  56. Author = "Ed Kolar (M3004)"
  57. string = "HH  Opened Door by "author;call outputthendelay 1
  58.  
  59.  
  60. /*Program variable initialization */
  61. /*      VariableNumbers:    */
  62.  
  63. MaxPlayers = 20        /* max number of players allowed by sysop */
  64. Dir = "Doors:Horses/"
  65. reps = 1
  66.  
  67. /**********************************************************************/
  68. /*               MY STANDARD TEMPLATE STARTS HERE                     */
  69. /**********************************************************************/
  70.  
  71. call getvar Doorname,LineNumber,1
  72. username=result
  73. call getvar DoorName,LineNumber,21
  74. handlename=result
  75. call getvar DoorName,LineNumber,11
  76. ncalls=result
  77. call getvar DoorNmae,LineNumber,14
  78. bbs_path=result
  79. call getvar DoorName,LineNumber,4
  80. city=result
  81. call getvar DoorName,LineNumber,5
  82. state=result
  83. call getvar DoorName,LineNumber,7
  84. telnum=result
  85. call getvar DoorName,LineNumber,20
  86. access=result
  87. call getvar DoorName,LineNumber,9
  88. width=result-2
  89. call getvar DoorName,LineNumber,8
  90. mode=result
  91. co = mode
  92. gfx = co
  93.  
  94. if mode = 1 then mode = "Color"
  95. ELSE mode = "B/White"
  96. if mode = "Color" then colr = "NONE"
  97. ELSE colr = "MONO"
  98. IF gfx ~= "0" THEN DO
  99.    black = '' ; blackback = ''
  100.    red = '' ; redback = ''
  101.    green = '' ; greenback = ''
  102.    yellow = '' ; yellowback = ''
  103.    blue = '' ; blueback = ''
  104.    magenta = '' ; magentaback = ''
  105.    cyan = '' ; cyanback = ''
  106.    white = '' ; whiteback = ''
  107.    italics = ''
  108.    bold = ''
  109.    los = "H"
  110.    los1 = "C";los2 = "C";los3 = "B"
  111.    normal = ''
  112.    cls = '0C'x||''
  113.    yesno = white"("green"y"white"/"red"N"white")"
  114.    noyes = white"("green"Y"white"/"red"n"white")"
  115. END
  116. ELSE DO
  117.    black = '' ; blackback = ''
  118.    red = '' ; redback = ''
  119.    green = '' ; greenback = ''
  120.    yellow = '' ; yellowback = ''
  121.    blue = '' ; blueback = ''
  122.    magenta = '' ; magentaback = ''
  123.    cyan = '' ; cyanback = ''
  124.    white = '' ; whiteback = ''
  125.    italics = ''
  126.    bold = ''
  127.    los = ""
  128.    normal = ''
  129.    cls = '0C'x
  130.    yesno = '(y/N)'
  131.    noyes = '(Y/n)'
  132. signal byeforcolor
  133. END
  134.  
  135. if exists(dir"INUSE") then do
  136.       call open file, (dir"INUSE"), 'R'
  137.       WHOON = readln(file);call close file
  138.          if right(whoon,1) = linenumber then signal start0
  139.       string =  cls;call output
  140.       string =  program" is currently being played by "WHOON" on line "right(whoon,1);call output
  141.       string =  "Try back in a little while...";call outputthendelay 2
  142.       call blank
  143.       call close file
  144.       call pause
  145.       signal byeinuse
  146. end
  147. start0:
  148. if exists(dir"INUSE") then do
  149.    flnm=dir"inuse"
  150.    call deletefile
  151. end
  152. if ~exists(dir"INUSE") then do;call open file, (dir"INUSE"), 'W'
  153. call writeln file, handlename||" "||linenumber;call close file;end
  154.  
  155.  
  156. /**********************************************************************/
  157. /*               MY STANDARD TEMPLATE ENDS HERE                       */
  158. /**********************************************************************/
  159.  
  160. /**********************************************************************/
  161. /*                        BBS VARIABLES                               */
  162. /**********************************************************************/
  163.  
  164. sysop = 'ED KOLAR'                                /* PUT YOUR NAME HERE   */
  165. Sysopname = 'MR. ED'                              /* PUT YOUR NAME HERE   */
  166. BBSname = 'Chalkboard I & II BBS Network'         /*  ETC....             */
  167. Progname = 'Chalkboard Downs '                    /* Change below to your name but match the spacings*/
  168. Exit_string = "         "yellowback||black||bold" Now returning you to that Wonderful Chalkboard I & II BBS "
  169. Exit_string2 = blue"              Chalkboard I & II BBS  "white"203-449-8100"
  170. Exit_string41 = normal"  "yellowback||black||bold"  Now returning you to that wonderful "
  171. Exit_string42 = normal"  "yellowback||black||bold"        Chalkboard I & II BBS         "normal||cyan
  172. Guessadd = 50
  173.  
  174. /**********************************************************************/
  175. /*                 End of BBS VARIABLES                               */
  176. /**********************************************************************/
  177.  
  178. /**********************************************************************/
  179. /*               START OF ACTIUAL PROGRAM                             */
  180. /**********************************************************************/
  181.  
  182.  
  183. Udate = time(N)            /* get current date & time         */
  184. Hname.1 = "Tumble Weed"
  185. Hname.2 = "Frisky Girl"
  186. Hname.3 = "Citation"
  187. Hname.4 = "Thunder"        /* CHANGE THESE NAMES TO ANYTHING THAT SUITS YOU... */
  188. Hname.5 = "Whirlaway"
  189. Hname.6 = "Seabiscuit"
  190. Hname.7 = "Comet"
  191. Hname.8 = "Old-Nag"
  192.  
  193. MAIN:
  194.   call random(1,10,time(s))
  195.   CALL PLAYERFILE
  196.   CALL CHECKBALANCE
  197.   Choice = 0
  198.   Do until Choice = 5 | Choice = 'Q'
  199.      string =  CLS;call output
  200.      string =  yellow"                    *********************************";call output
  201.      string =  magenta"                       Welcome to "green||progname;call output
  202.      string =  yellow"                    *********************************";call output
  203.      call blank
  204.      string =  yellow"                       1)"green" Read Instructions";call output
  205.      string =  yellow"                       2)"green" View Scoreboard";call output
  206.      string =  yellow"                       3)"green" Millionaires Club";call output
  207.      string =  yellow"                       4)"green" Go to the Track!";call output
  208.      string =  yellow"                       5)"green" Quit";call output
  209.      call blank
  210.      string =  yellow"                    ***************************";call output
  211.      call blank
  212.      string = "                    What would you like to do?  ";call getkey
  213. call check
  214.  Choice=upper(hot)
  215.      If Choice = 1 | Choice = 'I' then CALL INSTRUCT
  216.      else If Choice = 2 | Choice = 'S' then CALL SCOREBOARD
  217.      else If Choice = 3 | Choice = 'M' then CALL MILLIONS
  218.      else If Choice = 4 | Choice = 'T' then CALL THETRACK
  219.   end
  220.   CALL BYE
  221. signal exit_normal
  222.  
  223. PLAYERFILE:
  224.   string =  CLS;call output
  225.   string =  yellow"CChecking player file...";call output
  226.   call blank
  227.   AcctBal = 100
  228.   Flag = 0
  229.   nplayers = 0
  230.  
  231.   if ~exists(dir||'Dplayers') then do     /* Create a Players file if needed*/
  232.     call open(file1,dir||'Dplayers', 'W')
  233.     call writeln(file1,'0')              /* There are no players as yet */
  234.     call close(file1)
  235.    end
  236.  
  237.    call open(file1,dir||'Dplayers', 'R')      /* Read in existing player info */
  238.      nplayers = readln(file1)        /* Get current number of players */
  239.       if nplayers = 0 then signal newfile
  240.      do i = 1 to nplayers
  241.         player.i = readln(file1)     /*Read a player's name*/
  242.         score.i = readln(file1)      /*Read a player's score*/
  243.         if player.i = handlename then do  /*find user's acct balance*/
  244.        AcctBal = score.i           /*set user's acct balance*/
  245.            string =  white"CI see you have bet here before!";call output
  246.            string =  white"CYour account balance is:  $"green||AcctBal;call output
  247.            Flag = 1                   /*signal player was found*/
  248.         end
  249.      end
  250.    call close(file1)
  251. Newfile:
  252.    if Flag = 0 then do                 /*if player was not found in file*/
  253.        if nplayers < MaxPlayers then do
  254.          string =  white" A new player!!";call output
  255.          string =  white" You will be given"green" $100"white" to start you out!";call output
  256.          nplayers = nplayers + 1
  257.          player.nplayers = handlename
  258.          score.nplayers = AcctBal
  259. string = nplayers" Handle is "handlename;call lclmsg
  260.          end
  261.        else if nplayers >= MaxPlayers then do
  262.          call blank
  263.          string =  "Sorry there is no room for another gambler at the track!";call output
  264.          string =  "Talk to "SysopName" maybe he/she can do something about that!";call output
  265.          CALL BYE
  266.        end
  267.     end
  268.   CALL PAUSE
  269. RETURN
  270.  
  271. CHECKBALANCE:
  272.   LowBal = "FALSE"
  273.   If AcctBal <= 2 then do
  274.     LowBal = "TRUE"
  275.     call blank
  276.  
  277.     string =  white"It seems your account balance of $"green||AcctBal||white" is too low to place any bets.";call output
  278.     call blank
  279.     string = "Would you like to try to win $"guessadd" with no strings attached? ";call msg;string = noyes;call getkeyry
  280. call check
  281.  Flag = hot
  282.     /*if flag = 'NULL' then flag = "Y"*/
  283.         call blank
  284.     If Flag = "Y" then do
  285.       call blank;call blank
  286.       string = cyan"Okay, Pick a number between "white"1 "magenta;call msg;string = "and "white"5"cyan":  ";length = 1;call input
  287. call check
  288.  Guess=typed;if upper(guess) = 'NULL' then guess = "0"
  289.       RNum = RANDOM(1,5)
  290.       if Guess = RNum then do
  291.          call blank
  292.          string =  white"BYou guessed it!!! Adding "green||guessadd||white" to your Account Balance...";call output
  293.          call blank
  294.          AcctBal = AcctBal + guessadd
  295.          LowBal = "FALSE"
  296.          end
  297.       else do
  298.             if guess = '0' then call message doorname,linenumber,red||cyanback" If you don't pick a number you will never win at this! "normal||cyan,1
  299.          call blank
  300.          string =  white"Sorry the number was "red||RNum||white".  Try again sometime!";call output
  301.          call blank
  302.          end
  303.     end
  304.     else do
  305.       call blank
  306.       string =  magenta"Okay fine...but you won't be able to place any bets until ";call output
  307.       string =  "you have more money!!";call output
  308.       call blank
  309.       end
  310.     CALL PAUSE
  311. end
  312. RETURN
  313.  
  314. INSTRUCT:
  315.   string =  CLS;call output
  316.   if exists(dir||'Horsence') then do
  317.     call open(docs,dir||'horsence', 'R')
  318.       do while ~eof(docs)
  319.         line = readln(docs)
  320.         string =  cyan||line;call output
  321.       end
  322.     call close(docs)
  323.   end
  324.   else do
  325.     string =  white"Horsence-Instructions file was not found...";call output
  326.     string =  white"Notify "cyan||Sysopname||white"!";call output
  327.   end
  328.   call blank
  329.   CALL PAUSE
  330. RETURN
  331.  
  332. SCOREBOARD:
  333.   string =  CLS "Sorting Scores.............";call output
  334.   CALL SORTSCORES
  335.   Flag = 1
  336.   i = 1
  337.   j = 1
  338.   More = 'Y'
  339.   Do Forever
  340.      if More ~= 'Y' then break
  341.      Do while Flag = 1
  342.         string =  CLS;call output
  343.         string =  yellow"                    *******************************";call output
  344.         string =  magenta"                              SCOREBOARD";call output
  345.         string =  yellow"                    *******************************";call output
  346.         Flag = 0
  347.      end
  348.      if player.j = handlename then Score.j = AcctBal
  349.      P = Left(Player.j,20,' ')   /*Pad end of handle with spaces*/
  350.      string =  "                       "P"  $"Score.j;call output
  351.      i = i + 1
  352.      j = j + 1
  353.      if j > Nplayers then break
  354.      else if j <= Nplayers & i = 11 then do
  355.          Flag = 1
  356.          i = 0          /* Only display 10 names per page */
  357.          string =  yellow"                    *******************************";call output
  358.         string = yellow"                    Do you want to see more? ";call msg;string = noyes;call getkeyry
  359.         call check
  360.         more = upper(hot);if more = 'NULL' then more = "Y"
  361.          iterate
  362.        end
  363.      else if j <= Nplayers & i < 11 then iterate
  364.   end
  365.   if More = 'Y' then string =  yellow"                    *******************************";call output
  366.   CALL PAUSE
  367. RETURN
  368.  
  369. MILLIONS:
  370. drop hot
  371. call blank
  372. call blank
  373. if exists(dir'Dmillions') then do
  374.     call open(mill,dir||'Dmillions', 'R')
  375.     j = 0
  376.     i = 0
  377.     do while ~eof(mill)
  378.        do while j = 0
  379.           string =  CLS;call output
  380.           string =  yellow"             ***********************************************";call output
  381.           string =  yellow"             *"magenta"              MILLIONAIRES CLUB             "yellow" *";call output
  382.           string =  yellow"             ***********************************************";call output
  383.           j = 1
  384.        end
  385.        line = readln(mill)
  386.        parse var line p1 p2 p3 p4 p5 p6 p7 p8 p9
  387.        if length(p1) <10 then do
  388.           p1=p1||" "||p2
  389.           p2=p3;p3=p4;p4=p5;p5=p6;p6=p7;p7=p8
  390.        end
  391.        line = magenta||p1||cyan"  reached   "green||p3||cyan" at "yellow||p5||cyan" on "yellow||p7
  392.        string =  "       "line;if p1 = '' then iterate;call output
  393.        i = i + 1
  394.        if i = 10 then do;call blank;call blank
  395.           j = 0
  396.           i = 0
  397.           string = magenta"             More?  "yesno;call getkeyrn
  398.           if hot = "N" then do
  399.              call close(mill)
  400.              leave
  401.           end
  402.           else iterate
  403.  
  404.             call PAUSE
  405.           end
  406.         end
  407.     call close(mill)
  408.   end
  409.   else do
  410.     string =  magenta"There are no millionaires yet...";call output
  411.   end
  412.   call blank
  413. if hot ~= "N" then  CALL PAUSE
  414.  
  415. RETURN
  416.  
  417. CHECKMILLIONS:
  418.   if acctbal >= 1000000 then do
  419.     string =  magenta" ";call output
  420.     string =  "Congratulations!!!! You have become a Millionaire!!";call output
  421.     string =  "Adding your name to this elite group of gamblers....";call output
  422.     call blank
  423.     line = left(handlename,22,'.')||"  reached   $"AcctBal||" at "||left(time(n),5)||" on "||date(u)
  424.     if ~exists(dir'Dmillions') then do     /* Create a Dmillions file if needed*/
  425.       call open(fileM,dir||'Dmillions', 'W')
  426.       call writeln(fileM, line)  /* Put player in file */
  427.       call close(fileM)
  428.     end
  429.     else do
  430.       call open(fileM,dir||'Dmillions', 'A')
  431.       call writeln(fileM,line)   /* Add player to file */
  432.       call close(fileM)
  433.     end
  434.     AcctBal = 1000
  435.     string =  white"Your new account balance is"green" $1,000.";call output
  436.     call blank
  437.     string = white"Would you like to see the Millionaires Club list? ";call msg;string = noyes;call getkeyry
  438.         call check
  439.     more = upper(hot)
  440.     If More = "Y"| More = "NULL" then CALL MILLIONS
  441.   end
  442. RETURN
  443.  
  444. SORTSCORES:
  445.   /* Straight Selection Sort */
  446.   do i = 1 to (Nplayers - 1)
  447.      do j = (i+1) to Nplayers
  448.         if Score.i < Score.j then do
  449.           Temp = Score.i
  450.           Score.i = Score.j
  451.           Score.j = Temp
  452.           Temp = Player.i
  453.           Player.i = Player.j
  454.           Player.j = Temp
  455.         end
  456.      end
  457.   end
  458. RETURN
  459.  
  460. THETRACK:
  461.   Another = "Y"
  462.   Do While Another = "Y"
  463.        CALL CHECKBALANCE
  464.     If LowBal = "FALSE" then do
  465.        CALL BOOKIE
  466.        CALL GETBETS
  467.        CALL RACE
  468.        CALL WINNERS
  469.        call blank
  470.        string = magenta"Do you want to play another race? "noyes;call getkeyry
  471.         call check
  472.        Another = upper(hot)
  473.        if another = 'NULL' then another = "Y"
  474.  
  475.      end
  476.      else Another = "N"
  477.   end
  478. RETURN
  479.  
  480. BOOKIE:
  481.   /* Choose the odds on the horses */
  482.   do i = 1 to 8
  483.     WOdds.i = random(1,15)    /* Pick a random number*/
  484.     POdds.i = Left(WOdds.i *.75,pos('.', WOdds.i*.75) -1)
  485.     SOdds.i = Left(WOdds.i *.5,pos('.', WOdds.i*.5) -1)
  486.   end
  487.  
  488.   /* Set all bets to zero */
  489.   do i = 1 to 3
  490.     WHorse.i = 0
  491.     WBet.i = 0
  492.   end
  493.  
  494.   string =  CLS;call output
  495.   string =  yellow"*********************************************************************";call output
  496.   string =  magenta"                         PLACE YOUR BETS!!";call output
  497.   string =  yellow"*********************************************************************";call output
  498.   string =  magenta"  No.         Horse           Win Odds     Place Odds     Show Odds";call output
  499.   string =  magenta"  ---    ---------------      --------     ----------     ---------"cyan;call output
  500.   do i = 1 to 8
  501.     tes1 = right(Hname.i,16,' ')
  502.     tes2 = right(WOdds.i,14,' ')
  503.     tes3 = right(POdds.i,12,' ')
  504.  
  505.     string = right(i,4,' ');call msg                   /* Horse No.    */
  506.     string = tes1;call msg                             /* Horse's name */
  507.     string = tes2":1";call msg                         /* Win Odds     */
  508.     string = tes3":1";call msg                         /* Place Odds   */
  509.     string =  right(SOdds.i,12,' ')":1";call output    /* Show Odds    */
  510.   end
  511.   string =  yellow"*********************************************************************";call output
  512.   call blank
  513. RETURN
  514.  
  515. GETBETS:
  516. wbetistring =  "                                                                 B"
  517.   str.1 = "WIN: "
  518.   str.2 = "PLACE: "
  519.   str.3 = " SHOW: "
  520.   i = 1
  521.   do forever
  522.     /* Position cursor for each bet */
  523.     string =  "HBB      ";call output
  524.     ab = Left(AcctBal,10,'.')
  525.     string =  white"Your account balance is:"green"  $"AB||white;call output
  526.     do j = 1 to 3
  527.       string =  "                                                                           ";call output
  528.     end
  529.     string =  "A";call output
  530.  
  531.     if i > 3 then break       /* Check for all bets in*/
  532.  
  533.     if AcctBal < 2 then break  /* Not enough money to bet anymore */
  534.  
  535.     /* Get the horse number to bet on for each: win, place, show */
  536.    string = yellow"Enter the horse number to " str.i ;call msg;string = cyan;call getkey
  537.  
  538.    WHorse.i=upper(hot);if upper(hot) ~= 'Q'& (upper(hot) <1|upper(hot)>8) then WHorse.i = 'NULL'
  539.     string = magenta||WHorse.i' 'yellow;if whorse.i = 'NULL' then string = '';call output
  540.  
  541.     CALL CHECK
  542.     if WHorse.i = 'NULL' then do
  543.        /* Check if user pressed return, if so there is no bet on this round */
  544.        WBet.i = 0
  545.        i = i + 1
  546.        iterate
  547.     end
  548.     else
  549.         if WHorse.i = 'Q' then call bye
  550.         if WHorse.i < 1 | WHorse.i > 8 then do
  551.        /* Make sure horse number bet on is within range */
  552.        string = "1H            ";call msg
  553.        string =  magenta"Invalid "cyan"Horse "magenta"number.  "white"Try again"red"!"yellow;call outputthendelay 1
  554.         string =  "                                                                    B";call output
  555.         iterate
  556.     end
  557.     if Whorse.i ~= 'NULL' then do
  558.        /* If a horse is being bet on then get the amount of the bet */
  559.        string = "and how much do you want to bet:  "magenta;length = 4;call input;if typed = 'NULL' then typed = '0'
  560.        WBet.i=upper(typed)
  561.        call check
  562.        if WBet.i >= 2 & WBet.i <= AcctBal & WBet.i <= 2000 then do
  563.          /* make sure the amount of the bet is within range */
  564.          AcctBal = AcctBal - WBet.i
  565.          i = i + 1
  566.          iterate
  567.        end
  568.        else if WBet.i < 2 then do
  569.          /* if bet is too low then redo */
  570.         string =  "1H          ";call msg
  571.          string =  magenta"Sorry you must bet at least"green" $2."magenta"  "white"Try again"red"!"yellow;call msgthendelay 1
  572.           call blank
  573.         iterate
  574.        end
  575.        else if WBet.i > AcctBal then do
  576.          /* if bet is too high then redo */
  577.         string =  "1H      ";call msg
  578.          string =  magenta"You can not bet more than your account balance of: "green" $"AcctBal||magenta". "white"Try again"red"!"yellow;call outputthendelay 2
  579.          call blank
  580.         iterate
  581.        end /* else */
  582.        else if WBet.i > 2000 then do
  583.          /* if bet is too high then redo */
  584.          string =  "1H     ";call msg
  585.          string =  magenta"You can not bet more than "green"$2,000."magenta" "white"Try again"red"!"yellow;call outputthendelay 1
  586.          call blank
  587.         iterate
  588.        end /* else */
  589.      end /* else do */
  590.  /* 'message' "" */
  591.   end /* do forever */
  592. string =  red"Bringing the horses out onto the track..."green"  Please wait..";call outputthendelay 1
  593.  
  594.   if AcctBal < 2 then do
  595.         string =  "BYou have bet as much as you can.  The window is now closed!!";call outputthendelay 1;end
  596. /*  string =  "B";call output
  597.  CALL PAUSE*/
  598. RETURN
  599.  
  600. RACE:
  601.   string =  CLS"H";call output  /* clear screen and go to home position */
  602.   call blank
  603.   string =  white"";call output
  604.   call blank
  605. call blank
  606.   /* The race itself is 55 spaces long */
  607.   string =  green"++++++++++++|"red"Start"yellow"-------------------------------------"green"Finish|";call output
  608. /*'message' '' */
  609.   do i = 1 to 8
  610.     string =  magenta||RIGHT(Hname.i, 12,' ')"|";call output
  611.     Count.i = 15    /* reset all horse counters */
  612.   end
  613.   string = green"++++++++++++|"yellow"------------------------------------------------"green"|";call output
  614.   string =  white;call output
  615.   win = 0    /* no winning horse yet */
  616.   place = 0  /* no place horse yet */
  617.   show = 0   /* no show horse yet */
  618.  
  619.   j = random(1,8)  /* pick random horse to start out of gate */
  620.   Flag = "Go"
  621. call pause1
  622.   Do while Flag = "Go"
  623.     i = j
  624.     j = 1  /* always start at 1 after 1st time through loop */
  625.     do while i <= 8                                     /* cycle through each horse and add up their 'scores' */
  626.       RNum = random(1,5)                                /* Pick a random number*/
  627.       string = ""i+6";"Count.i"H ";call msg
  628.  
  629.       Count.i = Count.i + RNum                          /* Add the number to the current horse's count */
  630.                                                         /* Draw the horse's new position if he has not already crossed finish line*/
  631.       If (i ~= Win) & (i ~= Place) & (i ~= Show) then do
  632.         string = ""i+6";"Count.i"H"i;call msg
  633.       end
  634.  
  635.  
  636.       /* Check for win, place, and show horse */
  637.       If Count.i >= 62 then do
  638.  
  639.          If Win = 0 then do
  640.             Win = i  /* remember winning horse's number */
  641.             string =  ""6+i";"Count.i"H"||cyan||" W "white||HName.i;call output
  642.          end
  643.          else if (Place = 0) & (i ~= Win) then do
  644.             Place = i  /* remember place horse's number */
  645.             string =  ""6+i";"Count.i"H"||cyan||" P "white||HName.i;call output
  646.          end
  647.          else if (Show = 0) & (i ~= Win) & (i ~= Place) then do
  648.             Show = i   /* remember show horse's number */
  649.             string =  ""6+i";"Count.i"H"cyan" S "white||HName.i;call output
  650.             i = 8  /* race is over */
  651.             Flag = "Stop"  /* signal end of race */
  652.          end
  653.        end /* If Count.i >= 55 then do */
  654.  
  655.        i = i + 1
  656.     end  /* Do while i <= 8 */
  657.   end /* Do while Flag = "Go" */
  658.   string =  "HBB";call output
  659.  /* CALL PAUSE2 */
  660. RETURN
  661.  
  662. WINNERS:
  663. call blank
  664. string =  cyan"Horse #"Win" "white||HName.win||cyan" is the winner!!";call output
  665. If WHorse.1 = 'NULL' then call message doorname,linenumber,red"You did not bet on a horse to win!",1
  666. else do
  667.    string =  "You bet $"WBet.1" on Horse #"WHorse.1" to win.";call output
  668.    If WHorse.1 = Win then do
  669.        Won = WBet.1 * WOdds.Win
  670.        AcctBal = AcctBal + Won  + WBet.1
  671.        string =  yellow"Congratulations! You "green"WIN"yellow" $"green||Won||magenta" on your win bet!";call output
  672.     end
  673.     else do
  674.         string =  yellow"Sorry you "cyan"LOST"yellow" on your win bet.";call output;end
  675.   end
  676.   call blank
  677.  
  678.   string =  cyan"Horse #"Place" "white||HName.place||cyan" placed!";call output
  679.   If WHorse.2 = 'NULL' then call message doorname,linenumber,red"You did not bet on a horse to place!",1
  680.   else do
  681.     string =  "You bet $"WBet.2" on Horse #"WHorse.2" to place.";call output
  682.     If (WHorse.2 = Place) | (WHorse.2 = Win) then do
  683.        Won = WBet.2 * WOdds.Place
  684.        AcctBal = AcctBal + Won + WBet.2
  685.        string =  yellow"Congratulations! You "green"WIN $"Won||yellow" on your place bet!";call output
  686.     end
  687.     else do;string =  yellow"Sorry you "cyan"LOST"yellow" on your place bet.";call output;end
  688.   end
  689.   call blank
  690.  
  691.   string = cyan"Horse #"Show" "white||HName.show||cyan" showed.";call output
  692.   If WHorse.3 = 'NULL' then call message doorname,linenumber,red"You did not bet on a horse to show!",1
  693.  
  694.   else do
  695.     string = "You bet $"WBet.3" on Horse #"WHorse.3" to show.";call output
  696.     If (WHorse.3 = Show) | (WHorse.3 = Place) | (WHorse.3 = Win) then do
  697.        Won = WBet.3 * WOdds.Show
  698.        AcctBal = AcctBal + Won + WBet.3
  699.        string = yellow"Congratulations! You "green"WIN"yellow" $"Won||yellow" on your show bet!";call output
  700.     end
  701.     else do
  702.         string =  yellow"Sorry you "cyan"LOST"yellow" on your show bet."
  703.         call output
  704.     end
  705. end    /*call pause*/
  706. RETURN
  707.  
  708. PAUSE:
  709.  
  710.   call blank
  711.   call getreturn
  712.   call blank
  713.  
  714. RETURN
  715.  
  716. PAUSE2:
  717.  
  718.   call getreturn
  719.   string =  ""cls;call output
  720.  
  721. RETURN
  722.  
  723. PAUSE1:
  724.  
  725.   string =  "H";call output
  726.   string = cyan"Press any key to Start the RACE...";call getkey
  727.   string =  "H                                           ";call output
  728.   string =  "HTHEY'RE OFFl!!!";call output
  729.  
  730. RETURN
  731.  
  732. BYE:
  733.     CALL CHECKMILLIONS
  734. byeforcolor:
  735.         if co = 0 then do
  736.                 call blank
  737.                 string =  "  I'm sorry but you MUST have ANSI COLOR and ANSI POSITIONING here.";call outputthendelay 2
  738.                 signal exit_normal
  739. end
  740.         string = cls;call output
  741.         call blank
  742.         call blank
  743.  
  744.         string =  yellow"                   Brought to you by "cyan||sysop;call output
  745.         call blank
  746.         string = exit_string2;call output
  747.         call blank
  748.         string =  yellow"                Ported over to Mebbsnet by "white"Mr. Ed";call output
  749.         call blank
  750.         call blank
  751.         call blank
  752.  
  753.     CALL SORTSCORES
  754.     /* Rewrite PlayersFile */
  755.     call close(file1)
  756.     call open(file1,dir||'Dplayers', 'W')
  757.     call writeln(file1,NPlayers)
  758.       do i = 1 to NPlayers
  759.         if player.i = handlename then Score.i = AcctBal
  760.         call writeln(file1, player.i)
  761.         call writeln(file1, score.i)
  762.       end
  763.     call close(file1)
  764. if exists(dir'INUSE') then do
  765.     call blank
  766.     address command "delete "||dir||"INUSE"
  767.     address
  768.     call blank
  769. end
  770. signal exit_normal
  771.  
  772.  
  773. byeinuse:
  774.         if handlename = sysopname then do
  775.                 string = 'Do you want to delete the INUSE as Bogus??? 'noyes;call getkeyry
  776.                         if upper(hot) = "Y"|upper(hot) = "NULL" then do
  777.                                 address command "delete "||dir||"INUSE"
  778.                                 address
  779.                                 signal start0
  780.                         end
  781. end
  782. call EXIT_normal
  783.  
  784.  
  785. /*******************************  Procedures   *************************/
  786.  
  787.  
  788. Exit_Normal:
  789. call blank;call blank;call blank;call blank;call blank
  790. string = exit_string;call outputthendelay 2
  791.  
  792. call Exit_Door DoorName,LineNumber
  793. exit 0
  794.  
  795. Exit_Normal40:
  796. call blank;call blank;call blank;call blank;call blank
  797. string = exit_string41;call output
  798. string = exit_string42;call outputthendelay 2
  799.  
  800. call Exit_Door DoorName,LineNumber
  801. exit 0
  802.  
  803. DELETEFILE:
  804.  
  805. address command "delete "flnm
  806. address
  807.  
  808. return
  809.  
  810. GETRETURN:
  811.  
  812. string = center(CYAN||ITALICS" Press RETURN when ready..."NORMAL,width)
  813. call hotkey doorname,linenumber,string
  814. hot=""
  815. return
  816.  
  817. GETKEYRN:
  818.  
  819. call hotkey doorname,linenumber,string
  820. hot=upper(result)
  821. if hot = "Y" then do
  822.         string =green" Yes"
  823.         call output
  824. end
  825. else do                    /* yesno = "(y/N)"*/
  826.         hot = "N"
  827.         string = red" No"
  828.         call output
  829. end
  830. return
  831.  
  832. GETKEYRY:
  833.  
  834. call hotkey doorname,linenumber,string
  835. hot=upper(result)
  836. if hot = "N" then do
  837.         string = red" No"
  838.         call output
  839. end                        /* noyes = "(Y/n)"*/
  840. else do
  841.         hot = "Y"
  842.         string = green" Yes"
  843.         call output
  844. end
  845. return
  846.  
  847. GETKEY:
  848.  
  849. call hotkey doorname,linenumber,string
  850. hot=upper(result)
  851. return
  852.  
  853. INPUT:
  854.  
  855. call prompt doorname,linenumber,string,length
  856. typed=result
  857. return
  858.  
  859. OUTPUTTHENDELAY:
  860. arg reps
  861. call message doorname,linenumber,string,1
  862. do x = 1 to reps
  863. address command "wait 1"
  864. address
  865. end
  866. reps = 1
  867. return
  868.  
  869. OUTPUT:
  870.  
  871. call message doorname,linenumber,string,1
  872. return
  873.  
  874. MSGTHENDELAY:
  875. arg reps
  876. call message doorname,linenumber,string,0
  877. do x = 1 to reps
  878. address command "wait 1"
  879. address
  880. end
  881. reps = 1
  882. return
  883.  
  884. MSG:
  885.  
  886. call message doorname,linenumber,string,0
  887. return
  888.  
  889. BLANK:
  890.  
  891. blnk = " "
  892. call message doorname,linenumber,blnk,1
  893. return
  894.  
  895. GETOUT:
  896.  
  897. call blank
  898. call Exit_Door DoorName,LineNumber
  899. exit 0
  900.  
  901. Carrier:
  902.  
  903. call CDetect doorname,linenumber
  904. cd=result
  905. return
  906.  
  907. drophim:
  908.  
  909. call HangUp DoorName,LineNumber
  910. exit 0
  911.  
  912. readgr:
  913. call ReadGra doorname,linenumber,string
  914. return
  915.  
  916. readfl:
  917.  
  918. call ReadFile doorname,linenumber,string
  919. return
  920.  
  921. lclmsg:
  922.  
  923. call LocalMessage doorname,linenumber,string,1
  924. return
  925.  
  926. check:      /* check for lost carrier or spaced-out player */
  927.  
  928. call carrier
  929. if cd = "No carrier!" then signal drophim
  930. return
  931.  
  932.  
  933. /*************************  End of Procedures  ************************/
  934.  
  935. /**************************ERROR******Procedures*****************************/
  936.  
  937.  
  938. IOERR:
  939.     err_line = SIGL ; sev = RC ; code = sev
  940. string ="**Crash** Looks like we got an I/O error somewhere!"
  941. call output
  942.  
  943.     signal log_it
  944.  
  945. ERROR:
  946.     err_line = SIGL ; sev = RC ; code = sev
  947. string ="**Crash** Looks like we got some sort of error!"
  948. call output;trace A
  949. say err_line sev code
  950.     signal log_it
  951.  
  952. SYNTAX:
  953.     err_line = SIGL ; sev = RC ; code = sev
  954. string ="**Crash** Looks like we got a syntax error somewhere!"
  955. call output
  956.  
  957.         signal log_it
  958.  
  959. log_it:
  960. trace off
  961.     string ="Looks like we're gonna have to bail outta this mess......"
  962.     call output
  963. /*--------------------------------LOG-ERRORS----------------------------*/
  964. call blank
  965. string = "Inform Sysop to check the error log!"
  966. call outputthendelay 1
  967. if ~exists('bbs:logs') then makedir('BBS:Logs')
  968. if ~exists('BBS:Logs/Errlog') then call open(err,'BBS:Logs/Errlog','W')
  969. else call open(err,'BBS:Logs/Errlog','A')
  970. call writeln(err,date() time());call writeln(err,name" - "||doorname)
  971. call writeln(err,"Line - "err_line" Code - "code" User - "username);call writeln(err,errortext(code))
  972. call writeln(err,"");call close(err)
  973.  
  974. call Exit_Door doorname,linenumber
  975. exit 0
  976.  
  977.